﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace Ordering
{
    public class DBConn
    {
        static string ConnectionString = "Server=CNBJSAPT02;Initial Catalog=Mylunch;Integrated Security=True";
        SqlConnection conn = new SqlConnection(ConnectionString);

        public DBConn()
        {
            this.Connect();
        }

        //~DBConn()
        //{
        //    this.conn.Close();
        //}

        public SqlConnection Connect()
        {
            if(conn.State != ConnectionState.Open) conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                Console.WriteLine("connection has opened");
                return conn;
            }
            return null;
        }

        public string test()
        {
            DataSet ds = new DataSet();
            SqlDataAdapter daR = new SqlDataAdapter("select * from Shop", conn);
            daR.Fill(ds, "Shop");
            return ds.Tables[0].Rows[0][0].ToString();
        }
    }
}
